/*
 *  控件参数管理
 */
#include "view.h"
#include "view_def.h"
#include "util_crc32.h"
#include <string.h>

ViewInfo::ViewInfo(
    string name,
    int32_t width,
    int32_t height,
    int32_t rObj,
    int32_t rType)
{
    Reset(name, width, height, rObj, rType);
}

uint32_t ViewInfo::Crc32()
{
    /* 本体内存校验 */
    uint32_t ret = UtilCrc32(this, sizeof(ViewInfo));
    /* 深层内存校验 */
    ret = text.Crc32(&UtilCrc32, ret);
    return ret;
}

void ViewInfo::Reset(
    string name,
    int32_t width,
    int32_t height,
    int32_t rObj,
    int32_t rType)
{
    this->name = name;

    /* --- 位置范围 ---  */
    this->width = width;
    this->height = height;
    this->rType = rType;
    this->rObj = rObj;

    rErrX = rErrY = 0;

    /* --- 符号标记 --- */
    enable = true;
    visable = true;
    overDraw = false;
    enableFocus = false;
    enableOperate = false;

    /* --- 控件形状--- */
    shapeType = VST_RECT;
    memset(&shape, 0, sizeof(shape));
    shapeColor = 0;
    shapeColorBg = 0;
    shapeMarginTop = 0;
    shapeMarginBottom = 0;
    shapeMarginLeft = 0;
    shapeMarginRight = 0;

    /* --- 图片填充 --- */
    picture = NULL;
    picReplaceEnable = false;
    picReplaceColor = 0;
    picReplaceColorBy = 0;

    /* --- 文字 --- */
    text.Clean();
    textFont = VFT_DEFAULT;
    textColor = 0;
    textSize = 0;
    textBold = 0;
    textDegree = 0;
    textSpaceX = 0;
    textSpaceY = 0;
    textAutoEnter = false;
    textAutoScroll = false;
    textCenterX = true;
    textCenterY = true;
    textMarginTop = 0;
    textMarginBottom = 0;
    textMarginLeft = 0;
    textMarginRight = 0;

    /* --- 事件回调 --- */
    viewCallback = NULL;
    priv = NULL;
}
